package com.winhxd.b2c.customer.controller;

import com.winhxd.b2c.common.constant.BusinessCode;
import com.winhxd.b2c.common.domain.ResponseResult;
import com.winhxd.b2c.common.domain.customer.condition.ShoppingMallRuleCondition;
import com.winhxd.b2c.common.domain.customer.vo.ShoppingMallRuleVO;
import com.winhxd.b2c.common.feign.customer.ShoppingMallRuleServiceClient;
import com.winhxd.b2c.customer.service.ShoppingMallRuleService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author lishaoping
 * @Description:
 * @date 2019年1月7日20:33:20
 */
@Api(value = "api - Shopping", tags = "Shopping-Mall")
@RestController
public class ShoppingMallRuleServiceController implements ShoppingMallRuleServiceClient {

    @Autowired
    private ShoppingMallRuleService shaoppingMallRuleService;

    private Logger logger = LoggerFactory.getLogger(ShoppingMallRuleServiceController.class);

    @Override
    public ResponseResult<Boolean> saveShoppingMallRule(@RequestBody ShoppingMallRuleCondition condition) {
        ResponseResult<Boolean> result = new ResponseResult<Boolean>();
        try {
            result.setData(shaoppingMallRuleService.saveShoppingMallRule(condition));
        } catch (Exception e) {
            logger.error("saveShoppingMallRule保存商城营业设置失败：",e);
            result.setCode(BusinessCode.CODE_1001);
        }
        return result;
    }

    @Override
    public ResponseResult<ShoppingMallRuleVO> findShoppingMallRule(@RequestBody ShoppingMallRuleCondition condition) {
        ResponseResult<ShoppingMallRuleVO> result = new ResponseResult<ShoppingMallRuleVO>();
        try {
            result.setData(shaoppingMallRuleService.findShoppingMallRule(condition));
        } catch (Exception e) {
            logger.error("findShoppingMallRule查询商城营业设置失败：",e);
            result.setCode(BusinessCode.CODE_1001);
        }
        return result;
    }
}
